<?php
// 更新主动报工记录状态为已审核
try {
    $pdo = new PDO('mysql:host=127.0.0.1;dbname=order;charset=utf8mb4', 'order', '2R1P1i1F6xGBkAYd');
    
    echo "更新主动报工记录状态...\n";
    
    // 将所有记录状态改为已审核，并设置审核时间
    $stmt = $pdo->prepare("UPDATE fa_scanwork_active_report SET status = 1, audit_time = ? WHERE id IN (1, 2, 3)");
    $stmt->execute([time()]);
    
    $affectedRows = $stmt->rowCount();
    echo "更新了 {$affectedRows} 条记录\n";
    
    // 验证更新结果
    $stmt = $pdo->query("SELECT id, status, audit_time FROM fa_scanwork_active_report");
    $records = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo "更新后的记录状态:\n";
    foreach ($records as $record) {
        echo "ID: {$record['id']}, 状态: {$record['status']}, 审核时间: " . ($record['audit_time'] ? date('Y-m-d H:i:s', $record['audit_time']) : 'NULL') . "\n";
    }
    
} catch (PDOException $e) {
    echo "数据库错误: " . $e->getMessage() . "\n";
}
?> 